package de.tabiteuea.gui.models;

/**
 * Singleton that provides the InputModel.
 * 
 * This ensures, that all classes uses the same model.
 * 
 * 
 * @author Sebastian Lippert
 * 
 */

public class ModelProvider {

	private static final ModelProvider INSTANCE = new ModelProvider();

	/**
	 * The model that holds all user input and project information
	 */
	private InputModel inputModel;
	private boolean isSaveAllowed = false;

	/*
	 * private empty constructor to realize singleton pattern
	 */

	private ModelProvider() {
	}

	/**
	 * Getter for Singleton Instance of the provider
	 * 
	 * @return Instance
	 */

	public static ModelProvider getInstance() {
		return INSTANCE;
	}

	/**
	 * Getter for InputModel
	 * 
	 * @return InputModel
	 */

	public InputModel getInputModel() {
		if (inputModel == null)
			return new InputModel();

		return inputModel;
	}

	/**
	 * Setter for InputModel
	 * 
	 * @param InputModel
	 */

	public void setInputModel(InputModel inputModel) {

		if (inputModel != null) {

			this.inputModel = inputModel;
			isSaveAllowed = true;
		}
	}

	/**
	 * Depending on the existence of an InputModel a boolean will be returned.
	 * 
	 * @return boolean value
	 */

	public boolean isSaveAllowed() {
		return isSaveAllowed;
	}

}
